<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="echarts.js"></script>
    <script src="../../三段/jquery.js"></script>
    <script src="roma.js"></script>
  </head>
  <body>
    <div id="main" style="width: 700px; height: 600px"></div>
    <button onclick="fun()">点击</button>
  </body>
  <script>
    var option = {
      legend: {},
      tooltip: {},
      dataset: {
        // 提供一份数据。
        source: [
          ['username', '2014', '2016', '2017'],
          ['Matcha Latte', 83.3, 85.8, 93.7],
          ['Milk Tea', 83.1, 73.4, 55.1],
          ['Cheese Cocoa', 86.4, 65.2, 82.5],
          ['Walnut Brownie', 72.4, 53.9, 39.1],
        ],
      },
      // 声明一个 X 轴，类目轴（category）。默认情况下，类目轴对应到 dataset 第一列。
      xAxis: { type: 'category' },
      // 声明一个 Y 轴，数值轴。
      yAxis: {},
      // 声明多个 bar 系列，默认情况下，每个系列会自动对应到 dataset 的每一列。
      series: [{ type: 'bar' }, { type: 'bar' }, { type: 'bar' }],
    }
    var myChart = echarts.init(document.getElementById('main'))
    myChart.setOption(option)
    function fun() {
      data = [
        ['username', '2014', '2016', '2017'],
        ['Matcha Latte', 55.3, 55.8, 55.7],
        ['Milk Tea', 55.1, 55.4, 55.1],
        ['Cheese Cocoa', 86.4, 65.2, 82.5],
        ['Walnut Brownie', 72.4, 53.9, 39.1],
      ]
      option.dataset.source = data
      console.log(option)
      myChart.setOption(option)
    }
  </script>
</html>
